home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / xref_v1.1.lha / XRef / Tools / rexx / rexxxref.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-09  |  2.0 KB  |  89 lines

  1. /*
  2. ** $PROJECT: rexxxref.library
  3. **
  4. ** $VER: rexxxref.c 1.1 (08.01.95)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1995
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 08.01.95 : 001.001 : initial
  16. */
  17.  
  18. #include "rexxxref.h"
  19.  
  20.  
  21. LibCall struct Library *LibInit (REGD0 struct RexxXRefBase *rxb, REGA0 BPTR seglist, REGA6 struct Library * sysbase)
  22. {
  23.    rxb->rxb_SegList = seglist;
  24.    rxb->rxb_SysBase = sysbase;
  25.  
  26.    if(rxb->rxb_SysBase->lib_Version >= 37)
  27.    {
  28.       if((rxb->rxb_XRefBase      = OpenLibrary ("xref.library", 1)))
  29.       {
  30.          if((rxb->rxb_RexxSysBase = OpenLibrary("rexxsyslib.library",36)))
  31.          {
  32.             rxb->rxb_IntuitionBase = OpenLibrary ("intuition.library",37);
  33.             rxb->rxb_DOSBase       = OpenLibrary ("dos.library",      37);
  34.             rxb->rxb_UtilityBase   = OpenLibrary ("utility.library",  37);
  35.          } else
  36.          {
  37.             CloseLibrary(rxb->rxb_XRefBase);
  38.             rxb = NULL;
  39.          }
  40.       } else
  41.          rxb = NULL;
  42.    } else
  43.       rxb = NULL;
  44.  
  45.   return((struct Library *) rxb);
  46. }
  47.  
  48. LibCall LONG LibOpen (REGA6 struct RexxXRefBase *rxb)
  49. {
  50.    LONG retval = (LONG) rxb;
  51.  
  52.    /* Use an internal use counter */
  53.    rxb->rxb_Lib.lib_OpenCnt++;
  54.    rxb->rxb_Lib.lib_Flags &= ~LIBF_DELEXP;
  55.  
  56.    return (retval);
  57. }
  58.  
  59. LibCall LONG LibClose (REGA6 struct RexxXRefBase *rxb)
  60. {
  61.    LONG retval = NULL;
  62.  
  63.    if (rxb->rxb_Lib.lib_OpenCnt)
  64.       rxb->rxb_Lib.lib_OpenCnt--;
  65.  
  66.    if(rxb->rxb_Lib.lib_Flags & LIBF_DELEXP)
  67.        retval = LibExpunge (rxb);
  68.  
  69.    return (retval);
  70. }
  71.  
  72. LibCall LONG LibExpunge(REGA6 struct RexxXRefBase *rxb)
  73. {
  74.    BPTR seg = rxb->rxb_SegList;
  75.  
  76.    Remove((struct Node *) rxb);
  77.  
  78.    CloseLibrary(rxb->rxb_UtilityBase);
  79.    CloseLibrary(rxb->rxb_DOSBase);
  80.    CloseLibrary(rxb->rxb_XRefBase);
  81.    CloseLibrary(rxb->rxb_RexxSysBase);
  82.    CloseLibrary(rxb->rxb_IntuitionBase);
  83.  
  84.    FreeMem((APTR)((ULONG)(rxb) - (ULONG)(rxb->rxb_Lib.lib_NegSize)), rxb->rxb_Lib.lib_NegSize + rxb->rxb_Lib.lib_PosSize);
  85.  
  86.    return((LONG) seg);
  87. }
  88.  
  89.